import store from "@/store"

//变量的名称就是指令的名字
export const imgerror={
  inserted:function(el,bindings){
    // console.log(el);
    // console.log(bindings);
    el.onerror=()=>{
      // console.log('图片加载失败给一个默认的图片地址');
      el.src=bindings.value
    }
  }
}

//指令实现按钮级别的权限控制不同的用户，按钮的显示隐藏
export const allow={
  inserted:function(el,bindings){
    const points =store.state.user.userinfo.roles.points
    if(!points.includes(bindings.value)){
      el.style.display='none'
    }
  }
}
export const focus ={
  inserted: function(el,bindings){
    el.focus()
  }
}